//
//  HewardPayNumberController.m
//  OnionHome
//
//  Created by fengjie on 2019/9/22.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "HewardPayNumberController.h"
#import "HewardSelectPayTyprController.h"
#import "FJCustomKeyboardView.h"

@interface HewardPayNumberController ()
/**输入框*/
@property (nonatomic,strong)UITextField*textFiled;

@end

@implementation HewardPayNumberController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createUI];
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self setNavBarBackgroundAndClearColor];
}
-(void)createUI{
    self.view.backgroundColor = UIColorFromRGB(0xF5F7F5);
    
    UIImageView * userIcon = UIImageView.new;
    ViewRadius(userIcon, 36);
    userIcon.image = IMAGE_NAMED(@"userIconDefut");
    userIcon.image = [Utilis getRandomUserImage];
    
    UILabel * userName = UILabel.new;
    userName.textColor = UIColorFromRGB(0x273323);
    userName.font = PingFangSC_Regular(14);
    userName.textAlignment =NSTextAlignmentCenter;
    userName.text = @"小猫馋厨房";
    
    UIView * view = [self createBottomView];
    
    [self.view addSubview:userIcon];
    [self.view addSubview:userName];
    [self.view addSubview:view];
    
    [userIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(K_TopHeight);
        make.width.height.mas_equalTo(72);
    }];
    
    [userName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(userIcon.mas_bottom).offset(4);
    }];
    
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.mas_equalTo(0);
        make.top.mas_equalTo(userName.mas_bottom).offset(24);
    }];
}
-(UIView *)createBottomView{
    UIView * view = UIView.new;
    view.backgroundColor = KWhiteColor;
    
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect: self.view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(15,15)];
    //创建 layer
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = self.view.bounds;
    //赋值
    maskLayer.path = maskPath.CGPath;
    view.layer.mask = maskLayer;

    UILabel * label = UILabel.new;
    label.textColor = UIColorFromRGB(0x273323);
    label.font = PingFangSC_Medium(14);
    label.text = @"打赏金额";
    
    UILabel * iconLabel = UILabel.new;
    iconLabel.textColor = UIColorFromRGB(0x273323);
    iconLabel.font = PingFangSC_Medium(50);
    iconLabel.text = @"¥";

    UIView * lineView = UIView.new;
    lineView.backgroundColor = SeparatorColor;
    
    [view addSubview:label];
    [view addSubview:iconLabel];
    [view addSubview:self.textFiled];
    [view addSubview:lineView];

    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(24);
    }];
    
    
    [iconLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(label.mas_bottom).offset(16);
        make.width.mas_equalTo(30);
    }];
    
    [self.textFiled mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(iconLabel.mas_right).offset(16);
        make.centerY.mas_equalTo(iconLabel);
        make.right.mas_equalTo(-16);
        make.height.mas_equalTo(50);
    }];
    
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.right.mas_equalTo(-16);
        make.top.mas_equalTo(self.textFiled.mas_bottom).offset(5);
        make.height.mas_equalTo(0.5);
    }];
    
    return view;
}

-(UITextField*)textFiled{
    if(!_textFiled){
        _textFiled=[UITextField new];
        _textFiled.placeholder = @"0";
        _textFiled.font = PingFangSC_Medium(50);
//        _textFiled.keyboardType = UIKeyboardTypeDecimalPad;
//        _textFiled.returnKeyType = UIReturnKeyContinue;
//        _textFiled.keyboardType = UIKeyboardTypeNumberPad;
        
        FJCustomKeyboardView *keyboardView = [[FJCustomKeyboardView alloc] init];
        keyboardView.completeTitle = @"打赏";
        _textFiled.inputView = keyboardView;
        kWeakSelf(weakSelf);
        keyboardView.backBlock = ^{
            [weakSelf.navigationController pushViewController:[HewardSelectPayTyprController new] animated:YES];
        };

    }
    return _textFiled;
}

@end
